package com.clementheliou.cheliou.dal.model.department;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.clementheliou.cheliou.dal.model.base.BaseEntity;
import com.clementheliou.cheliou.dal.model.country.Country;

/**
 * Entity dedicated to the departments.
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @see {@link BaseEntity};
 * @see {@link Entity};
 * @see {@link Serializable};
 * @see {@link Table}.
 * @since 1.0
 */
@Entity
@Table(name = "department")
public class Department extends BaseEntity implements Serializable {

	/**
	 * UID for serialization.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private static final long serialVersionUID = 1026743543262739384L;

	/**
	 * The country this department belongs to.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private Country country;

	/**
	 * The untranslatable name of the department.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private String name;

	/**
	 * The prefix of the zip code related to this department.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private String zipCodePrefix;

	/*
	 * Getters & setters.
	 */

	@GeneratedValue(generator = "seq_department")
	@Id
	@SequenceGenerator(name = "seq_department", sequenceName = "seq_department")
	public Integer getId() {
		return id;
	}

	@JoinColumn(name = "countryid", nullable = false)
	@ManyToOne
	@NotNull
	public Country getCountry() {
		return country;
	}

	public void setCountry(Country country) {
		this.country = country;
	}

	@Basic(optional = false)
	@Column(length = 100, nullable = false)
	@NotNull
	@Size(max = 100)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Basic(optional = false)
	@Column(length = 3, nullable = false)
	@NotNull
	@Size(max = 3)
	public String getZipCodePrefix() {
		return zipCodePrefix;
	}

	public void setZipCodePrefix(String zipCodePrefix) {
		this.zipCodePrefix = zipCodePrefix;
	}
}
